Repository navigation
Conversation
A quoted field after a two-character separator split across a read chunk was dropped when the input was streamed and kept when it was parsed in memory.
The scanner rewound to the start of the next record but left the bytes already read from that chunk only in a local buffer. The next read discarded them, so a quoted field was parsed differently from a file than from a string. Fixes ruby#397
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A two-character row separator can fall across the streaming reader's chunk boundary. The reader glued the separator back together, then left the scanner at the start of the next record while the bytes it had already taken from that chunk lived only in a local buffer. The next read discarded them. A quoted field was then parsed differently from a file than from a string:
The same bytes now produce the same result either way. An unclosed quote is rejected from a file as well as from a string, and a quote that does close round-trips, including the field that begins in the chunk after the split separator.
With a chunk size of 8, the old reader returned
[[7], [], [5, 4]]for the unclosed case and raised "Unclosed quoted field in line 4." for the closed case. After the change those are "Unclosed quoted field in line 2." and[[7], [20]].ruby run-test.rbis 536 tests, 4073 assertions, including the chunk-size-1 scanner run.Fixes #397